/*
 * ScanTask.cpp
 *
 *  Created on: 24.09.2012
 *      Author: Lapchinskiy
 */
#include "Global_includes.h"
#include "ScanTask.h"
ScanTask::ScanTask(uint8_t priority, ScanTaskId task_id) {
	sensorsInTask = 0;
	this->priority = priority;
	this->id = task_id;
	sensorList = new ArrayList<Sensor> [max_task_number];
}
ScanTask::ScanTask(uint8_t priority, ScanTaskId task_id, uint8_t obtEventMask,
		uint8_t timeEventMask) {
	sensorsInTask = 0;
	this->priority = priority;
	this->id = task_id;
	sensorList = new ArrayList<Sensor> [max_task_number];
}

ScanTask::~ScanTask() {
	delete[] sensorList;
}

ErrorCode ScanTask::execute(void) {
	for (uint16_t i = 0; i < sensorList->getSize(); i++) {
		sensorList->get(i)->scan();
	}
	return NO_ERRORx;
}

ErrorCode ScanTask::addSensorToScan(Sensor* sens) {
	return sensorList->add(sens);

}

uint8_t ScanTask::getId() const {
	return id;
}

void ScanTask::setId(uint8_t id) {
	this->id = id;
}

uint8_t ScanTask::getPriority() const {
	return priority;
}

void ScanTask::setPriority(uint8_t priority) {
	this->priority = priority;
}

uint16_t ScanTask::getSensorsInTask() const {
	return sensorsInTask;
}

void ScanTask::setSensorsInTask(uint16_t sensorsInTask) {
	this->sensorsInTask = sensorsInTask;
}

void ScanTask::setSensorList(ArrayList<Sensor> *sensorList) {
	this->sensorList = sensorList;
}

ErrorCode ScanTask::deleteTask(void) {
	delete[] sensorList;
	return NO_ERRORx;
}

